<?php
/**
 * (exporter)
 */
namespace App\Exporter\Stocking;

use App\Models\Product\ProductClassify;
use App\Models\Stocking\StockingSku;
use Encore\Admin\Grid\Exporters\ExcelExporter;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
class SkuSetDateExporter extends ExcelExporter implements WithMapping,WithHeadings
{

    protected $fileName = '设置备货月份.csv';

    protected $headings = ['品类','站点','季节性','生产周期','海运时效','海运最快可售','设定日期','预警'];

    public function map($model) : array
    {
        return [
            $model->classify->title ?? '',
            $model->area->area ?? '',
            ProductClassify::$_season[$model->classify->season ?? 3],
            $model->purchase_cycle,
            $model->sea_day,
            StockingSku::getSaleDate($model->sea_available),
            $model->set_date,
            $model->status  ? '未达预警' : '已达预警',
        ];
    }
}
